<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once "common.php";
class city
{
    function city()
    {
          global $baseinfo_c;
         $baseinfo_c =new baseinfo_common();
    }
     function insert($zh_hk,$en_us="",$zh_cn="")
    {
		global $baseinfo_c;
        if($zh_hk==null || $zh_hk=='')
        {
            return 0;//error
        }
        $strSql="INSERT INTO city(name_en_us,name_zh_hk,name_zh_cn,delete_flag) VALUE ('".$baseinfo_c->utf8trim($en_us)."','".$baseinfo_c->utf8trim($zh_hk)."','".$baseinfo_c->utf8trim($zh_cn)."',0);";
        
        $baseinfo_c->execSql($strSql);
    }
    function delete($keyValue)
    {
         global $baseinfo_c;
         $baseinfo_c->deleteRecord("city","cid",$baseinfo_c->utf8trim($keyValue));
    }
    function update($keyValue,$zh_hk,$en_us="",$zh_cn="")
    {
		global $baseinfo_c;
        $strSql="UPDATE city SET name_en_us='".$baseinfo_c->utf8trim($en_us)."',name_zh_hk='".$baseinfo_c->utf8trim($zh_hk)."',name_zh_cn='".$baseinfo_c->utf8trim($zh_cn)."' WHERE cid=".$baseinfo_c->utf8trim($keyValue).";";
         
         $baseinfo_c->execSql($strSql);
    }
    function select($pageSize,$pageNo,$where="")
    {
         global $baseinfo_c;
         return $baseinfo_c->getPageRecords("city","cid",$pageSize,$pageNo,$where);
    }
    function selectDetail($pageSize,$pageNo,$where="")
    {
         global $baseinfo_c;
         if($where=="")
         {
         $strSelectOrderBy="SELECT c.* FROM city c 
                            WHERE c.delete_flag=0
                            ORDER BY c.cid";
         }
         else
         {
              $where="c.name_zh_hk LIKE '%".$where."%'
            OR c.name_en_us LIKE '%".$where."%'
            OR c.name_zh_cn LIKE '%".$where."%'";
              
             $strSelectOrderBy="SELECT c.* FROM city c 
                            WHERE c.delete_flag=0 AND (".$where.")
                            ORDER BY c.cid";
         }
         return $baseinfo_c->getSqlPageRecords($strSelectOrderBy,$pageSize,$pageNo);
    }
   function getPages($pageSize,$where="") {
       if($where!="")
        {
            $where="name_zh_hk LIKE '%".$where."%'
            OR name_en_us LIKE '%".$where."%'
            OR name_zh_cn LIKE '%".$where."%'";
        }
        global $baseinfo_c;
        return $baseinfo_c->getTablePages("city",$pageSize,$where);
   }
}
?>
